<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
    <title>Table - Brand</title>
    <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i">
    <link rel="stylesheet" href="assets/fonts/fontawesome-all.min.css">
</head>

<body id="page-top">
<div id="app">
    <div id="wrapper">
        <nav class="navbar navbar-dark align-items-start sidebar sidebar-dark accordion bg-gradient-primary p-0">
            <div class="container-fluid d-flex flex-column p-0"><a class="navbar-brand d-flex justify-content-center align-items-center sidebar-brand m-0" href="#">
                    <div class="sidebar-brand-icon rotate-n-15"></div>
                    <div class="sidebar-brand-text mx-3"><span>主页</span></div>
                </a>
                <hr class="sidebar-divider my-0">
                <ul class="navbar-nav text-light" id="accordionSidebar">
                    <li class="nav-item"></li>
                    <li class="nav-item"><a class="nav-link active" href="user.html"><span>用户信息管理</span></a></li>
                    <li class="nav-item"><a class="nav-link" href="school.html">院校信息管理</a></li>
                    <li class="nav-item"><a class="nav-link" href="major.html"><span>专业信息管理</span></a></li>
                    <li class="nav-item"><a class="nav-link" href="../index.html"><span>返回用户主页</span></a></li>
                    <li class="nav-item"><a class="nav-link" @click="goOffline()"><span>退出登陆</span></a></li>
                </ul>
            </div>
        </nav>
        <div class="d-flex flex-column" id="content-wrapper">
            <div id="content">
                <nav class="navbar navbar-light navbar-expand bg-white shadow mb-4 topbar static-top">
                    <div class="container-fluid"><button class="btn btn-link d-md-none rounded-circle me-3" id="sidebarToggleTop" type="button"><i class="fas fa-bars"></i></button>
                        <form class="d-none d-sm-inline-block me-auto ms-md-3 my-2 my-md-0 mw-100 navbar-search">
                            <div class="input-group"><input class="bg-light form-control border-0 small" type="text" placeholder="搜索"><button class="btn btn-primary py-0" type="button"><i class="fas fa-search"></i></button></div>
                        </form>
                        <ul class="navbar-nav flex-nowrap ms-auto">
                            <li class="nav-item dropdown d-sm-none no-arrow"><a class="dropdown-toggle nav-link" aria-expanded="false" data-bs-toggle="dropdown" href="#"><i class="fas fa-search"></i></a>
                                <div class="dropdown-menu dropdown-menu-end p-3 animated--grow-in" aria-labelledby="searchDropdown">
                                    <form class="me-auto navbar-search w-100">
                                        <div class="input-group"><input class="bg-light form-control border-0 small" type="text" placeholder="Search for ...">
                                            <div class="input-group-append"><button class="btn btn-primary py-0" type="button"><i class="fas fa-search"></i></button></div>
                                        </div>
                                    </form>
                                </div>
                            </li>
                            <li class="nav-item dropdown no-arrow mx-1"></li>
                            <li class="nav-item dropdown no-arrow mx-1">
                                <div class="shadow dropdown-list dropdown-menu dropdown-menu-end" aria-labelledby="alertsDropdown"></div>
                            </li>
                            <li class="nav-item dropdown no-arrow">
                                <div class="nav-item dropdown no-arrow"><a class="dropdown-toggle nav-link" aria-expanded="false" data-bs-toggle="dropdown" href="#"><span class="d-none d-lg-inline me-2 text-gray-600 small">管理员</span></a>
                                    <div class="dropdown-menu shadow dropdown-menu-end animated--grow-in"><a class="dropdown-item" href="#"><i class="fas fa-user fa-sm fa-fw me-2 text-gray-400"></i>&nbsp;Profile</a><a class="dropdown-item" href="#"><i class="fas fa-cogs fa-sm fa-fw me-2 text-gray-400"></i>&nbsp;Settings</a><a class="dropdown-item" href="#"><i class="fas fa-list fa-sm fa-fw me-2 text-gray-400"></i>&nbsp;Activity log</a>
                                        <div class="dropdown-divider"></div><a class="dropdown-item" href="#"><i class="fas fa-sign-out-alt fa-sm fa-fw me-2 text-gray-400"></i>&nbsp;Logout</a>
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </nav>
                <div class="container-fluid">
                    <h3 class="text-dark mb-4">用户</h3>
                    <div class="card shadow">
                        <div class="card-header py-3">
                            <p class="text-primary m-0 fw-bold">用户信息</p>
                        </div>
                        <div class="card-body">
                            <div class="table-responsive table mt-2" id="dataTable" role="grid" aria-describedby="dataTable_info">
                                <table class="table my-0" id="dataTable">
                                    <thead>
                                        <tr>
                                            <th style="width: 66px;">用户ID</th>
                                            <th style="width: 104px;">姓名</th>
                                            <th style="width: 165px;">密码</th>
                                            <th style="width: 151px;">选课类型</th>
                                            <th style="width: 104px;">高考分数</th>
                                            <th style="width: 245px;">操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr v-for="user in userss" style="padding: 0px;margin: 0px;">
                                            <td>{{user.id}}</td>
                                            <td style="width: 115px;">{{user.name}}</td>
                                            <td>{{user.password}}</td>
                                            <td>{{user.type}}</td>
                                            <td>{{user.score}}</td>
                                            <td style="padding: 0px;margin: 0px;">
                                                <button class="btn btn-primary" type="button" style="width: 76.7031px;height: 36px;padding: 2px;margin: 2px;border-radius: 13px;">
                                                    <a class="link-light" :href="'user_change.html?id='+user.id"
                                                       style="text-decoration: none">修改</a>
                                                </button>
                                                <button class="btn btn-primary" type="button" @click="deleteUsers(user.id)" style="width: 76.7031px;height: 36px;
                                                padding: 2px;margin: 2px;border-radius: 13px;" data-bs-target="#modal-1" data-bs-toggle="modal">
                                                删除</button>
                                            </td>
                                        </tr>
                                    </tbody>
                                    <tfoot>
                                        <tr></tr>
                                    </tfoot>
                                </table>
                            </div>
                            <div class="row">
                                <div class="col">
                                    <nav class="float-start d-lg-flex justify-content-lg-end dataTables_paginate paging_simple_numbers">
                                        <ul class="pagination">
                                            <li class="page-item"><a class="page-link" href="javascript:;" v-if="page>1" class="page" @click="findAll(page-1)">上一页</a></li>
                                            <li class="page-item"><a class="page-link" href="javascript:;" v-if="page==1" class="page">上一页</a></li>
                                            <li  v-for="indexpage in totalPage">
                                                <span class="page-item"><a class="page-link" href="javascript:;" v-text="indexpage" @click="findAll(indexpage)"></a></span>
                                            </li>
                                            <li class="page-item"><a class="page-link" href="javascript:;" v-if="page==totalPage" class="page">下一页</a></li>
                                            <li class="page-item"><a class="page-link" href="javascript:;" v-if="page<totalPage" class="page" @click="findAll(page+1)">下一页</a></li>
                                        </ul>
                                    </nav>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <footer class="bg-white sticky-footer">
                <div class="container my-auto">
                    <div class="text-center my-auto copyright"><span>Copyright © 四组</span></div>
                </div>
            </footer>
        </div><a class="border rounded d-inline scroll-to-top" href="#page-top"><i class="fas fa-angle-up"></i></a>
    </div>
    <script src="assets/bootstrap/js/bootstrap.min.js"></script>
    <script src="assets/js/theme.js"></script>
</div>
</body>

</html>

<script src="../js/vue.js"></script>
<script src="../js/axios.min.js"></script>
<script>
    const app = new Vue({
        el:'#app',
        data:{
            users:{},
            src:"",
            subjects:[],
            isExists:0,
            userss:[],
            page:1,
            rows:10,
            totalPage:0,
            totals:0,
            realType:"",
        },
        methods:{
            goOffline(){
                const storage = window.localStorage;
                storage.setItem("online","off");
                alert("登出成功, 点击进入登陆页面")
                location.href='../login.html';
            },
            findAll(indexpage){
                if(indexpage) this.page = indexpage;
                axios.get("http://localhost:8080/users/findByPage?page="+this.page+"&rows="+this.rows).then((res)=>{
                    console.log(res.data)
                    this.userss = res.data.users;
                    this.totalPage = res.data.totalPage;
                    this.totals = res.data.totals;
                });
            },
            deleteUsers(id){
                axios.get("http://localhost:8080/users/deleteUsers?id="+id).then((res)=>{
                    confirm("你确定要删除该用户吗? ")
                    console.log("id="+id+"已被删除");
                    location.reload();
                });
            },
            startAdd(){
                this.addShow = true;
                this.selectShow = false;
            },
        },
        created(){
            if(window.localStorage.getItem("online")!=="on"){
                window.location='../login.html';
            }else {
                this.findAll();
                console.log("this.userss.length  "+this.userss)
            }
        }
    })
</script>